有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何修复处理安装时遇到的错误

我想用this post重新安装意外删除的java

正如上面关于运行sudo apt install default-jre的帖子中提到的,我遇到了以下错误:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
default-jre is already the newest version (2:1.11-68ubuntu1~18.04.1).
0 upgraded, 0 newly installed, 0 to remove and 149 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up install-info (6.5.0.dfsg.1-2) ...
/usr/sbin/update-info-dir: 3: /etc/environment: JAVA_HOME: not found
dpkg: error processing package install-info (--configure):
 installed install-info package post-installation script subprocess returned error exit status 127
Errors were encountered while processing:
 install-info
E: Sub-process /usr/bin/dpkg returned an error code (1)

java --version的结果是:

Command 'java' not found, but can be installed with:

sudo apt install default-jre            
sudo apt install openjdk-11-jre-headless
sudo apt install openjdk-8-jre-headless 

apt list --installed | egrep 'jdk|jre'的结果是:

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

default-jre/bionic-updates,bionic-security,now 2:1.11-68ubuntu1~18.04.1 amd64 [installed]
default-jre-headless/bionic-updates,bionic-security,now 2:1.11-68ubuntu1~18.04.1 amd64 [installed]
openjdk-11-jre/bionic-updates,bionic-security,now 11.0.7+10-2ubuntu2~18.04 amd64 [installed]
openjdk-11-jre-headless/bionic-updates,bionic-security,now 11.0.7+10-2ubuntu2~18.04 amd64 [installed]
openjdk-8-jdk/bionic-updates,bionic-security,now 8u252-b09-1~18.04 amd64 [installed]
openjdk-8-jdk-headless/bionic-updates,bionic-security,now 8u252-b09-1~18.04 amd64 [installed]
openjdk-8-jre/bionic-updates,bionic-security,now 8u252-b09-1~18.04 amd64 [installed]
openjdk-8-jre-headless/bionic-updates,bionic-security,now 8u252-b09-1~18.04 amd64 [installed]

正如文章中提到的,我尝试了以下方法来修复错误:

sudo apt install --reinstall default-jre default-jdk default-jre-headless default-jdk-headless openjdk-11-jdk openjdk-11-jdk-headless openjdk-11-jre openjdk-11-jre-headless openjdk-8-jdk openjdk-8-jdk-headless openjdk-8-jre openjdk-8-jre-headless

但是,它给出了相同的错误

echo $JAVA_HOME的结果是: /usr/lib/jvm/java-11-openjdk-amd64/bin

echo $PATH的结果是:

/home/.local/bin:/home/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/bin:/usr/lib/jvm/jdk1.7.0/bin:/home/bin:/usr/lib/jvm/jdk1.7.0/bin:/usr/lib/jvm/java-11-openjdk-amd64/bin

我发现这些链接都断了

usr/share/man/man1/jar。1.gz

usr/share/man/man1/jarsigner。1.gz

usr/share/man/man1/java。1.gz

usr/share/man/man1/javac。1.gz

usr/share/man/man1/javadoc。1.gz

usr/share/man/man1/javah。1.gz

usr/share/man/man1/javap。1.gz

当尝试从接口打开这些文件时,收到一条警告消息,这些链接无法使用,因为它的替代项在“/etc/alternations/”中不存在

/usr/share/man/man1# update-alternatives --config java作为根用户的结果是:

update-alternatives: warning: alternative /usr/lib/jvm/java-11-openjdk-amd64/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: alternative /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java (part of link group java) doesn't exist; removing from list of alternatives
update-alternatives: warning: /etc/alternatives/java is dangling; it will be updated with best choice
There is no program which provides java.
Nothing to configure.

考虑到重新安装java的不便,因为它似乎未完全安装或删除,尝试使用this post完全卸载java

this post中所述,运行以下命令:

dpkg-query -W -f='${binary:Package}\n' | grep -E -e '^(ia32-)?(sun|oracle)-java' -e '^openjdk-' -e '^icedtea' -e '^(default|gcj)-j(re|dk)' -e '^gcj-(.*)-j(re|dk)' -e '^java-common' | xargs sudo apt-get -y remove

但即使这样,在处理过程中也会出现同样的错误

apt update && apt dist-upgrade的结果是:

Get:2 http://in.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:3 http://in.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Get:4 http://in.archive.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:5 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 DEP-11 Metadata [306 kB]
Get:6 http://in.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 DEP-11 Metadata [279 kB]
Get:7 http://in.archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 DEP-11 Metadata [2,468 B]
Get:8 http://in.archive.ubuntu.com/ubuntu bionic-backports/universe amd64 DEP-11 Metadata [7,972 B]
Get:9 http://in.archive.ubuntu.com/ubuntu bionic-security/main amd64 DEP-11 Metadata [43.8 kB]
Get:10 http://in.archive.ubuntu.com/ubuntu bionic-security/universe amd64 DEP-11 Metadata [49.2 kB]
Get:11 http://in.archive.ubuntu.com/ubuntu bionic-security/multiverse amd64 DEP-11 Metadata [2,464 B]
Fetched 943 kB in 4s (267 kB/s)                                        
Reading package lists... Done
Building dependency tree       
Reading state information... Done
148 packages can be upgraded. Run 'apt list --upgradable' to see them.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following NEW packages will be installed:
  libnetplan0 linux-headers-5.3.0-59 linux-headers-5.3.0-59-generic
  linux-image-5.3.0-59-generic linux-modules-5.3.0-59-generic
  linux-modules-extra-5.3.0-59-generic
The following packages will be upgraded:
  apport apport-gtk apt apt-utils aptdaemon aptdaemon-data bind9-host
  ca-certificates clamav clamav-base clamav-freshclam cups cups-bsd
  cups-client cups-common cups-core-drivers cups-daemon cups-ipp-utils
  cups-ppdc cups-server-common debootstrap distro-info-data dmeventd dmsetup
  dnsutils exim4 exim4-base exim4-config exim4-daemon-light file firefox
  firefox-locale-en gir1.2-javascriptcoregtk-4.0 gir1.2-snapd-1
  gir1.2-webkit2-4.0 intel-microcode iproute2 kmod libapt-inst2.0
  libapt-pkg5.0 libbind9-160 libclamav9 libcups2 libcupscgi1 libcupsimage2
  libcupsmime1 libcupsppdc1 libdevmapper-event1.02.1 libdevmapper1.02.1
  libdns-export1100 libdns1100 libexif12 libfreerdp-client2-2 libfreerdp2-2
  libirs160 libisc-export169 libisc169 libisccc160 libisccfg160
  libjavascriptcoregtk-4.0-18 libjpeg-turbo8 libjpeg-turbo8-dev libjson-c3
  libkmod2 libldap-2.4-2 libldap-common liblvm2app2.2 liblvm2cmd2.02
  liblwres160 libmagic-mgc libmagic1 libmysqlclient-dev libmysqlclient20
  libnss-myhostname libnss-systemd libopenexr22 libpam-systemd
  libpulse-mainloop-glib0 libpulse0 libpulsedsp libsmbclient libsnapd-glib1
  libsqlite3-0 libssl-dev libssl1.1 libsystemd0 libudev1 libvirt-bin
  libvirt-clients libvirt-daemon libvirt-daemon-driver-storage-rbd
  libvirt-daemon-system libvirt0 libwbclient0 libwebkit2gtk-4.0-37 libwinpr2-2
  linux-firmware linux-generic-hwe-18.04 linux-headers-generic-hwe-18.04
  linux-image-generic-hwe-18.04 linux-libc-dev lvm2 mysql-client-5.7
  mysql-client-core-5.7 mysql-server mysql-server-5.7 mysql-server-core-5.7
  netplan.io nplan openssl pulseaudio pulseaudio-module-bluetooth
  pulseaudio-utils python-apt-common python-flask python3-apport python3-apt
  python3-aptdaemon python3-aptdaemon.gtk3widgets python3-problem-report
  python3-software-properties python3-update-manager qemu-block-extra qemu-kvm
  qemu-system-common qemu-system-x86 qemu-utils remmina remmina-common
  remmina-plugin-rdp remmina-plugin-secret remmina-plugin-vnc samba-libs
  shotwell shotwell-common software-properties-common software-properties-gtk
  sqlite3 systemd systemd-sysv thunderbird thunderbird-gnome-support
  thunderbird-locale-en thunderbird-locale-en-us tzdata udev update-manager
  update-manager-core
148 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 3,777 kB/333 MB of archives.
After this operation, 349 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 sqlite3 amd64 3.22.0-1ubuntu0.4 [752 kB]
Get:2 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libsqlite3-0 amd64 3.22.0-1ubuntu0.4 [499 kB]
Get:3 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 intel-microcode amd64 3.20200609.0ubuntu0.18.04.1 [2,526 kB]
Fetched 3,777 kB in 11s (353 kB/s)                                             
Extracting templates from packages: 100%
Preconfiguring packages ...
Setting up install-info (6.5.0.dfsg.1-2) ...
/usr/sbin/update-info-dir: 3: /etc/environment: JAVA_HOME: not found
dpkg: error processing package install-info (--configure):
 installed install-info package post-installation script subprocess returned error exit status 127
Errors were encountered while processing:
 install-info
E: Sub-process /usr/bin/dpkg returned an error code (1)

请提供修复此限制安装或删除任何软件包的错误的建议


共 (0) 个答案